import { IsNumber, IsNotEmpty, IsOptional } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateShortsOrderDto {
  @ApiProperty({ description: '短剧ID', example: 1 })
  @IsNumber()
  @IsNotEmpty()
  shortsId: number;

  @ApiProperty({
    description: '章节ID数组（可选，不传则购买整个短剧）',
    required: false,
    type: [Number],
  })
  @IsOptional()
  @IsNumber({}, { each: true })
  chapterIds?: number[];
}

export class ShortsOrderResponseDto {
  @ApiProperty({ description: '订单ID' })
  id: string;

  @ApiProperty({ description: '用户ID' })
  userId: number;

  @ApiProperty({ description: '短剧ID' })
  shortsId: number;

  @ApiProperty({ description: '章节ID（可选）' })
  chapterId?: number;

  @ApiProperty({ description: '消耗的积分' })
  points: number;

  @ApiProperty({ description: '学习进度' })
  progress: number;

  @ApiProperty({ description: '创建时间' })
  createdAt: string;

  @ApiProperty({ description: '更新时间' })
  updatedAt: string;
}

export class BatchShortsOrderResponseDto {
  @ApiProperty({ description: '总消耗积分' })
  totalPoints: number;

  @ApiProperty({ description: '创建的订单列表' })
  orders: ShortsOrderResponseDto[];

  @ApiProperty({ description: '是否为VIP用户' })
  isVip: boolean;
}

export class ApiShortsOrderResponseDto {
  @ApiProperty({ description: '响应状态码', example: 200 })
  code: number;

  @ApiProperty({ description: '响应消息', example: 'success' })
  message: string;

  @ApiProperty({ description: '响应数据' })
  data: ShortsOrderResponseDto;

  @ApiProperty({ description: '时间戳' })
  timestamp: number;

  @ApiProperty({ description: '请求ID' })
  requestId: string;
}

export class ApiBatchShortsOrderResponseDto {
  @ApiProperty({ description: '响应状态码', example: 200 })
  code: number;

  @ApiProperty({ description: '响应消息', example: 'success' })
  message: string;

  @ApiProperty({ description: '响应数据' })
  data: BatchShortsOrderResponseDto;

  @ApiProperty({ description: '时间戳' })
  timestamp: number;

  @ApiProperty({ description: '请求ID' })
  requestId: string;
}

// 广告订单相关DTO
export class CreateAdOrderDto {
  @ApiProperty({ description: '短剧ID', example: 1 })
  @IsNumber()
  @IsNotEmpty()
  shortsId: number;

  @ApiProperty({ description: '章节ID', example: 1 })
  @IsNumber()
  @IsNotEmpty()
  chapterId: number;
}

export class AdOrderResponseDto {
  @ApiProperty({ description: '广告订单ID' })
  id: string;

  @ApiProperty({ description: '用户ID' })
  userId: number;

  @ApiProperty({ description: '短剧ID' })
  shortsId: number;

  @ApiProperty({ description: '章节ID' })
  chapterId: number;

  @ApiProperty({ description: '视频URL' })
  videoUrl: string;

  @ApiProperty({ description: '章节标题' })
  chapterTitle: string;

  @ApiProperty({ description: '订单类型' })
  type: string;

  @ApiProperty({ description: '消耗的积分' })
  points: number;

  @ApiProperty({ description: '创建时间' })
  createdAt: string;

  @ApiProperty({ description: '消息' })
  message: string;
}

export class ApiAdOrderResponseDto {
  @ApiProperty({ description: '响应状态码', example: 200 })
  code: number;

  @ApiProperty({ description: '响应消息', example: 'success' })
  message: string;

  @ApiProperty({ description: '响应数据' })
  data: AdOrderResponseDto;

  @ApiProperty({ description: '时间戳' })
  timestamp: number;

  @ApiProperty({ description: '请求ID' })
  requestId: string;
}

